package at.chl.genetic.function.math.node;

import java.util.List;

import at.chl.genetic.function.math.request.MathFunctionRequest;
import at.chl.genetic.function.math.result.MathFunctionResult;
import at.chl.genetic.function.math.types.MathParamType;
import at.chl.genetic.node.IDecisionNode;

public class ParamNode extends AbstractMathDecisionNode{
	
	
	public MathParamType paramChoice;

	/**
	 * 
	 * @param paramChoice = 
	 */
	public ParamNode(MathParamType paramType){
		this.paramChoice=paramType;
		setHash(createHashCode("PARAM"+paramType.toString()));
	}
	
	@Override
	public MathFunctionResult evaluate(MathFunctionRequest request) {
		switch(paramChoice){
		case PARAM_X: return new MathFunctionResult(request.getX());
		case PARAM_Y: return new MathFunctionResult(request.getY());
		}
		//TODO throw exception
		return null;
	}

	@Override
	public int getChildrenCount() {
	
		return 0;
	}

	@Override
	public void print(String tab) {
		System.out.println(tab+paramChoice);
	}

	@Override
	public List<IDecisionNode> getChildNodes() {
		// no need for action
		return null;
	}

	@Override
	public void setChildNodes(List<IDecisionNode> childNodes) {
		// no need for action
		
	}

	@Override
	public String getName() {
		return paramChoice.name();
	}

	@Override
	public IDecisionNode cloneNode() {
		IDecisionNode clone=new ParamNode(paramChoice);
		return clone;
	}
}
